package com.jinliang.thinkinspringweb.mvc.config;

import com.jinliang.thinkinspringweb.mvc.config.interceptor.MyHandlerInterceptor;
import com.jinliang.thinkinspringweb.mvc.config.interceptor.RateLimitBucketInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private RedisTemplate redisTemplate;
    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new MyHandlerInterceptor());
        registry.addInterceptor(new RateLimitBucketInterceptor(redisTemplate));

    }
}
